package indi.kider.server.schedule.job;

import indi.kider.server.schedule.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Created by shixj on 2018/5/22.
 */
@Component
@Configurable
@EnableScheduling
@EnableAsync
public class JobBeans {
    @Autowired
    BillService billService;
    @Autowired
    QiniuService qiniuService;
    @Autowired
    ApabusSerivce apabusSerivce;
    @Autowired
    SmsService smsService;
    //后台抽取

    /* *//**
     * 租房统计生成月报表
     * 每月1号凌晨2点启动
     */
    @Async
    @Scheduled(cron = "0 0 2 1 * ?")
    public void insertRentMonthReport(){
        apabusSerivce.statisticsRental();
    }

    /**
     * 后台生成账单分类月报表
     * 每月1号凌晨2点启动
     */
    @Async
    @Scheduled(cron = "0 0 2 1 * ?")
    public void saveBillCountByTypeModelList() {
        billService.saveBillCountByTypeModelList();
    }

    /**
     * 后台生成月报表
     * 每月1号凌晨2点启动
     */
    @Async
    @Scheduled(cron = "0 0 2 1 * ?")
    public void insertEmployeeBillCount() {
        billService.insertEmployeeBillCount();
    }
    /**
     * 结算账单
     * 每天凌晨2点启动
     */
    @Async
    @Scheduled(cron = "0 0 2 * * ?")
    public void autoBalance() {
        billService.autoBalance();
    }

    /**
     * 更新七牛token
     * 单位毫秒
     */
    @Async
    @Scheduled(fixedRate = 1000 * 60 * 60)
    public void updateUpToken() {
        qiniuService.updateUpToken();
    }


    /**
     * 发送消息
     * 房租即将到期
     * 每天8点启动
     */
    @Async
    @Scheduled(cron = "0 0 8 * * ?")
    public void getDueRentalBillList() {
        smsService.getDueRentalBillList();
    }
    /**
     * 发送消息
     * 房屋即将到期
     * 每天8点启动
     */
    @Async
    @Scheduled(cron = "0 0 8 * * ?")
    public void getDueRentList() {
        smsService.getDueRentList();
    }
    /**
     * 发送消息
     * 逾期水费提醒
     * 每天8点启动
     */
    @Async
    @Scheduled(cron = "0 0 8 * * ?")
    public void getOverdueWaterBillList() {
        //smsService.getOverdueWaterBillList();
    }
    /**
     * 发送消息
     * 逾期电费提醒
     * 每天8点启动
     */
    @Async
    @Scheduled(cron = "0 0 8 * * ?")
    public void getOverduePowerBillList() {
        //smsService.getOverduePowerBillList();
    }
    /**
     * 发送消息
     * 逾期网费提醒
     * 每天8点启动
     */
    @Async
    @Scheduled(cron = "0 0 8 * * ?")
    public void getOverdueNetBillList() {
        //smsService.getOverdueNetBillList();
    }
    /**
     * 发送消息
     * 逾期物业费提醒
     * 每天8点启动
     */
    @Async
    @Scheduled(cron = "0 0 8 * * ?")
    public void getOverdueEstateBillList() {
        //smsService.getOverdueEstateBillList();
    }
    /**
     * 发送消息
     * 逾期房租提醒
     * 每天8点启动
     */
    @Async
    @Scheduled(cron = "0 0 8 * * ?")
    public void getOverdueRentalBillList() {
        //smsService.getOverdueRentalBillList();
    }
}
